package org.kommii.encryption;

import org.apache.commons.codec.binary.Base64;

public class Base64Helper {
	 public static String encode(byte[] byteArray) {
//	        sun.misc.BASE64Encoder base64Encoder = new sun.misc.BASE64Encoder();
//	        return base64Encoder.encode(byteArray);
		 	return Base64.encodeBase64String(byteArray);
	    }

	    public static byte[] decode(String base64EncodedString) {
//	        sun.misc.BASE64Decoder base64Decoder = new sun.misc.BASE64Decoder();
//	        try {
//	            return base64Decoder.decodeBuffer(base64EncodedString);
//	        } catch (IOException e) {
//	            return null;
//	        }
	    	return Base64.decodeBase64(base64EncodedString);
	    }
	    
	    public static void main(String[] args){
	    	String str = "q茧俯+?Ew蹝颽睧械E鱷|恿漎m	鷈|滣0~喐m,?R柄進酱裶羋1疲\\绹";
	    	byte[] by = str.getBytes();
	    	String temp = encode(by);
	    	System.out.println(temp);
	    	byte[] by2 = decode("cbzruKkQKz9Fd9uSFO9hskXQtUUU93t808GdWQJtCfplfJz3MAN+Foa4bSw/UrH63029tNFxwWQxxqNcwIc=");
	    	String temp2 = new String(by2);
	    	System.out.println(temp2);
	    }
	    


}
